package org.ly817.my.spring.core.aop;

import org.ly817.my.spring.core.ITestService;
import org.ly817.victorinox.myspring.context.ApplicationContext;
import org.ly817.victorinox.myspring.context.ClassPathApplicationContext;

/**
 * Created by LuoYu on 2018/4/17.
 */
public class AopMain {
    public static void main(String[] args) throws Exception {
        ApplicationContext applicationContext = new ClassPathApplicationContext("myspring.xml");
        ITestService testService = (ITestService) applicationContext.getBean("testService");

        testService.hello();

//        ITestDao dao = (ITestDao) applicationContext.getBean("testDao");
//        dao.dosomething();
//        AdviceSupport adviceSupport = new AdviceSupport();
//        adviceSupport.setTargetSource(new TargetSource(testService,new Class[]{ITestService.class}));
//        adviceSupport.setMethodInterceptor(new TimerAdvice());



//        JdkDynamicAopProxy aopProxy = new JdkDynamicAopProxy(adviceSupport);

        // 生成的代理对象需要继承代理对象同样继承的接口
//        ITestService proxy = (ITestService)aopProxy.getProxy();
//        proxy.hello();

        // 自动切面注入
    }
}
